package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TcompanyDao;
import com.xy.manage.model.Tcompany;
import com.xy.manage.service.TcompanyService;

@Service
@Transactional
public class TcompanyServiceImpl extends BaseServiceImpl<Tcompany> implements
		TcompanyService {
	private TcompanyDao tcompanyDao;

	public TcompanyServiceImpl(TcompanyDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tcompanyDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tcompanyDao.checkExist("Tcompany", paraName, paraValue);
	}

	@Override
	public List<Tcompany> getTcompany(Map<String, Object> map) {
		return tcompanyDao.getTcompany(map);
	}
	@Override
	public Pagination getTcompanyByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tcompanyDao.getTcompanyByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tcompany save(Tcompany tcompany) {
	//	tcompany.setModtime(new Date());
		if(tcompany.getInfoid()==null){
			//新增
        	return super.save(tcompany);
		}else{
			//更新
			Tcompany tcompany1=tcompanyDao.get(tcompany.getInfoid());
			try {
				BeanUtil.copyNotNullProperties(tcompany1, tcompany);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tcompany1);
		}
	}
}